using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using Microsoft.TeamFoundation;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Proxy;

namespace CSharpDistilled.Diagnostics
{
    public partial class DiagnosticsStudio : Form
    {
        #region DiagnosticsStudio Private Fields

        private TeamFoundationServer m_server;

        #endregion

        #region public DiagnosticsStudio()

        /// <summary>
        /// Initializes a new instance of the <see cref="DiagnosticsStudio"/> class.
        /// </summary>
        public DiagnosticsStudio()
        {
            InitializeComponent();

            this.Text = SR.GetString(SR.DiagnosticsStudio);
        }

        #endregion

        #region private void ApplicationExit(object sender, EventArgs e)

        /// <summary>
        /// Handles the Click event of the ExitToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void ApplicationExit(object sender, EventArgs e)
        {
            Application.Exit();
        }

        #endregion

        #region private void ConnectToTeamFoundationServer(object sender, EventArgs e)

        /// <summary>
        /// Connects to Team Foundation Server.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void ConnectToTeamFoundationServer(object sender, EventArgs e)
        {
            m_server = TeamFoundationServerFactory.GetServer("https://tfs01.codeplex.com:443", new UICredentialsProvider());

            m_server.EnsureAuthenticated();

            //DomainProjectPicker domainProjectPicker = new DomainProjectPicker(DomainProjectPickerMode.AllowProjectSelect);

            //if (domainProjectPicker.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            //{
            //    m_server = domainProjectPicker.SelectedServer;

            //    m_server = TeamFoundationServerFactory.GetServer(m_server.Name, new UICredentialsProvider());

            //    Microsoft.TeamFoundation.Server.ProjectInfo[] projectInfo = domainProjectPicker.SelectedProjects;

            //    string tfsProjectName = projectInfo[0].Name;

            //    m_server.EnsureAuthenticated();
            //}
        }

        #endregion
    }
}